import request from '@/utils/request'

/**
 * 获取客户列表
 * @param {Object} params 查询参数
 */
export const getCustomerList = (params) => {
  return request({
    url: '/customers',
    method: 'get',
    params
  })
}

/**
 * 根据ID获取客户详情
 * @param {number} id 客户ID
 */
export const getCustomerById = (id) => {
  return request({
    url: `/customers/${id}`,
    method: 'get'
  })
}

/**
 * 创建客户
 * @param {Object} data 客户数据
 */
export const createCustomer = (data) => {
  return request({
    url: '/customers',
    method: 'post',
    data
  })
}

/**
 * 更新客户信息
 * @param {number} id 客户ID
 * @param {Object} data 客户数据
 */
export const updateCustomer = (id, data) => {
  return request({
    url: `/customers/${id}`,
    method: 'put',
    data
  })
}

/**
 * 删除客户
 * @param {number} id 客户ID
 */
export const deleteCustomer = (id) => {
  return request({
    url: `/customers/${id}`,
    method: 'delete'
  })
}

/**
 * 批量删除客户
 * @param {Array} ids 客户ID数组
 */
export const batchDeleteCustomers = (ids) => {
  return request({
    url: '/customers/batch',
    method: 'delete',
    data: { ids }
  })
}

/**
 * 根据状态获取客户列表
 * @param {string} status 客户状态
 */
export const getCustomersByStatus = (status) => {
  return request({
    url: `/customers/status/${status}`,
    method: 'get'
  })
}

/**
 * 根据护理等级获取客户列表
 * @param {string} careLevel 护理等级
 */
export const getCustomersByCareLevel = (careLevel) => {
  return request({
    url: `/customers/care-level/${careLevel}`,
    method: 'get'
  })
}

/**
 * 根据姓名搜索客户
 * @param {string} name 客户姓名
 */
export const searchCustomersByName = (name) => {
  return request({
    url: `/customers/search`,
    method: 'get',
    params: { name }
  })
}

/**
 * 根据年龄范围获取客户列表
 * @param {number} minAge 最小年龄
 * @param {number} maxAge 最大年龄
 */
export const getCustomersByAgeRange = (minAge, maxAge) => {
  return request({
    url: `/customers/age-range`,
    method: 'get',
    params: { minAge, maxAge }
  })
}

/**
 * 根据性别获取客户列表
 * @param {string} gender 性别
 */
export const getCustomersByGender = (gender) => {
  return request({
    url: `/customers/gender/${gender}`,
    method: 'get'
  })
}

/**
 * 获取活跃客户列表（按护理等级和年龄排序）
 */
export const getActiveCustomers = () => {
  return request({
    url: '/customers/active',
    method: 'get'
  })
}

/**
 * 获取客户统计信息
 */
export const getCustomerStats = () => {
  return request({
    url: '/customers/stats',
    method: 'get'
  })
}